<?php 
session_start();
$lang = $_SESSION['lang'];
if (empty($lang) || $lang == "EN") {
	include "../../value/value_en.php";
} else if($lang == "VN") {
	include "../../value/value_vn.php";
}
else {
	include "../../value/value_kr.php";
}
include '../../generallibraries/funcs.php';
include '../../operations/connection.php';

if(isset($_REQUEST['newname'])){
	if($_REQUEST['newname']!=""){
		if($_SESSION['thucthi']=="new"){
			$hamsort=" where ac_customer.CustomerName='".$_REQUEST['newname']."'";
			$sqlCustomer = generalFunctions::listCustomer("ac_customer.CustomerName",$hamsort);
			//echo $sqlCustomer;
			$rs=mysql_query($sqlCustomer);
			if(mysql_num_rows($rs)>0){
				$_SESSION['checknamecus']=$l_companynameexit;
				echo $_SESSION['checknamecus'];
			}else{
				//echo $sqlCustomer;
				$_SESSION['checknamecus']="ok";
			}
		}else if($_SESSION['thucthi']=="updel"){
			if(isset($_REQUEST['idcus'])){
				$hamsort=" where ac_customer.CustomerName='".$_REQUEST['newname']."' and ac_customer.CustomerID!='".$_REQUEST['idcus']."'";
				$sqlCustomer = generalFunctions::listCustomer("ac_customer.CustomerName",$hamsort);
				$rs=mysql_query($sqlCustomer);
				if(mysql_num_rows($rs)>0){
					$_SESSION['checknamecus']=$l_companynameexit;
					echo "huhuhu ".$_SESSION['checknamecus'];
				}else{
					//echo $sqlCustomer;
					$_SESSION['checknamecus']="ok";
				}
			}else{
				$_SESSION['checknamecus']="noid";
			}
		}else{
			$_SESSION['checknamecus']="unknow";
		}
	}else{
		$_SESSION['checknamecus']="null";
	}
}

mysql_close($connection);
?>